<!--
 * @Author: Soulmate
 * @Date: 2023-09-14 11:07:46
 * @LastEditTime: 2023-09-19 11:55:04
 * @LastEditors: Soulmate
 * @Description: 
 * @FilePath: \ruoyi-ui-vue3\src\views\index\analysis\index.vue
 * 版权声明
-->
<template>
    <div class="app-container">
        <el-row :gutter="15">
            <el-col :span="6" :xs="24">
                <el-card class="box-card">
                    <div class="dataFree">
                        <div class="header">
                            <div class="statistic-card">
                                <el-statistic :value="2122423">
                                    <template #title>
                                        <div class="title">
                                            年销售额
                                            <el-tooltip effect="dark" content="Number of users who logged into the product in one day" placement="top">
                                                <el-icon size="14"><QuestionFilled /></el-icon>
                                            </el-tooltip>
                                        </div>
                                    </template>
                                </el-statistic>
                                <div class="statistic-footer">
                                    <div class="footer-item">
                                        <span>周同比</span>
                                        <span class="red">
                                            35%
                                            <el-icon>
                                                <CaretTop />
                                            </el-icon>
                                        </span>
                                    </div>
                                    <div class="footer-item">
                                        <span>日同比</span>
                                        <span class="green">
                                            56%
                                            <el-icon>
                                                <CaretTop />
                                            </el-icon>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="footer">
                            <p>月销售额 ￥12,423</p>
                        </div>
                    </div>
                </el-card>
            </el-col>
            <el-col :span="6" :xs="24">
                <el-card class="box-card">
                    <div class="dataFree">
                        <div class="header">
                            <div class="statistic-card">
                                <el-statistic :value="9343">
                                    <template #title>
                                        <div class="title">
                                            订单总数
                                            <el-button style="width: 20px; height: 25px" :color="Mock.mock('@color()')" plain>日</el-button>
                                        </div>
                                    </template>
                                </el-statistic>
                                <div class="statistic-footer">
                                    <div class="chart">
                                        <EasyLineChart :height="20" :chartData="chartSmallLineData" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="footer">
                            <p>日访问量 8,324</p>
                        </div>
                    </div>
                </el-card>
            </el-col>
            <el-col :span="6" :xs="24">
                <el-card class="box-card">
                    <div class="dataFree">
                        <div class="header">
                            <div class="statistic-card">
                                <el-statistic :value="8988">
                                    <template #title>
                                        <div class="title">
                                            交易总额
                                            <el-button style="width: 20px; height: 25px" :color="Mock.mock('@color()')" plain>月</el-button>
                                        </div>
                                    </template>
                                </el-statistic>
                                <div class="statistic-footer">
                                    <div class="chart">
                                        <EasyBarChart :height="20" :chartData="chartSmallBarData" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="footer">
                            <p>转化率 85%</p>
                        </div>
                    </div>
                </el-card>
            </el-col>
            <el-col :span="6" :xs="24">
                <el-card class="box-card">
                    <div class="dataFree">
                        <div class="header">
                            <div class="statistic-card">
                                <el-statistic value="96%">
                                    <template #title>
                                        <div class="title">
                                            会员增量
                                            <el-button style="width: 20px; height: 25px" :color="Mock.mock('@color()')" plain>周</el-button>
                                        </div>
                                    </template>
                                </el-statistic>
                                <div class="gressContent">
                                    <el-progress :color="Mock.mock('@color()')" :percentage="96" :stroke-width="6" striped />
                                </div>
                            </div>
                        </div>
                        <div class="footer">
                            <div class="statistic-footer">
                                <div class="footer-item">
                                    <span>周同比</span>
                                    <span class="red">
                                        35%
                                        <el-icon>
                                            <CaretTop />
                                        </el-icon>
                                    </span>
                                </div>
                                <div class="footer-item">
                                    <span>日同比</span>
                                    <span class="green">
                                        56%
                                        <el-icon>
                                            <CaretTop />
                                        </el-icon>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
                </el-card>
            </el-col>
        </el-row>
        <el-row :gutter="15">
            <el-col :span="24" :xs="24">
                <el-card class="box-card positionRe">
                    <el-tabs v-model="tabActive" class="tabs" @tab-click="handleTabClick">
                        <el-tab-pane label="销售额" name="salesVolume">
                            <div class="paneBox" v-if="tabActive == 'salesVolume'">
                                <div class="lfChart">
                                    <div class="title">销售趋势</div>
                                    <div class="content">
                                        <EasyBarChart :chartData="chartBarData" />
                                    </div>
                                </div>
                                <div class="rgList">
                                    <div class="title">门店销售额排名</div>
                                    <div class="content">
                                        <div class="paneRow" v-for="(item, index) in paneData" :key="index">
                                            <div class="avatar">
                                                <el-button style="width: 25px; height: 25px" :color="item.levelColor" plain circle>{{ index + 1 }}</el-button>
                                            </div>
                                            <div class="info">
                                                <p>{{ item.paneName }}</p>
                                            </div>
                                            <div class="status">{{ item.paneNum }}</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </el-tab-pane>
                        <el-tab-pane label="访问量" name="pageView">
                            <div class="paneBox" v-if="tabActive == 'pageView'">
                                <div class="lfChart">
                                    <div class="title">访问量趋势</div>
                                    <div class="content">
                                        <EasyBarChart :chartData="chartBarData" />
                                    </div>
                                </div>
                                <div class="rgList">
                                    <div class="title">门店访问量排名</div>
                                    <div class="content">
                                        <div class="paneRow" v-for="(item, index) in paneData" :key="index">
                                            <div class="avatar">
                                                <el-button style="width: 25px; height: 25px" :color="item.levelColor" plain circle>{{ index + 1 }}</el-button>
                                            </div>
                                            <div class="info">
                                                <p>{{ item.paneName }}</p>
                                            </div>
                                            <div class="status">{{ item.paneNum }}</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </el-tab-pane>
                    </el-tabs>
                    <div class="searchChart">
                        <el-button-group class="ml-4">
                            <el-button
                                v-for="(item, index) in dateSearchGroup"
                                :key="index"
                                :type="item.value == dateSearch ? 'primary' : ''"
                                @click="dateSearch = item.value"
                                >{{ item.text }}</el-button
                            >
                        </el-button-group>
                        <el-date-picker
                            style="margin-left: 10px"
                            v-model="time"
                            type="daterange"
                            range-separator="至"
                            start-placeholder="开始时间"
                            end-placeholder="结束时间"
                            size="default"
                        />
                    </div>
                </el-card>
            </el-col>
        </el-row>
        <el-row :gutter="15">
            <el-col :span="18" :xs="24">
                <el-card class="box-card">
                    <template v-slot:header>
                        <div class="clearfix">
                            <span>最近1小时访问情况</span>
                        </div>
                    </template>
                    <div class="nearHourComeIn">
                        <EasyLineChart :chartData="chartLineData" />
                    </div>
                </el-card>
            </el-col>
            <el-col :span="6" :xs="24">
                <el-card class="box-card">
                    <template v-slot:header>
                        <div class="clearfix">
                            <span>热门搜索</span>
                        </div>
                    </template>
                    <div class="nearHourComeIn">
                        <EasyWordChart :chartData="chartWordData" />
                    </div>
                </el-card>
            </el-col>
        </el-row>
    </div>
</template>

<script lang="ts" setup name="Analysis">
import Mock from 'mockjs';
import { easyHookData } from './hook';

const {
    chartBarData,
    chartLineData,
    chartWordData,
    paneData,
    tabActive,
    time,
    dateSearch,
    dateSearchGroup,
    chartSmallBarData,
    chartSmallLineData,
    getPaneList,
    getBarChartData,
    getLineChartData,
    getWordCloudData,
    getOrderLineChartData,
    getPriceChartData,
} = easyHookData();

const handleTabClick = () => {
    getPaneList();
    getBarChartData();
};

onMounted(() => {
    handleTabClick();
    getLineChartData();
    getWordCloudData();
    getPriceChartData();
    getOrderLineChartData();
});
</script>

<style lang="scss" scoped>
@import '@/assets/styles/variables.module.scss';
.app-container {
    padding: 15px;
    .box-card {
        margin-bottom: 15px;

        ::v-deep(.el-card__body) {
            padding-bottom: 15px !important;
        }

        &.positionRe {
            position: relative;

            .searchChart {
                position: absolute;
                right: 10px;
                top: 10px;
                height: 40px;
                display: flex;
                align-items: center;
            }
        }
    }
    .dataFree {
        width: 100%;
        display: flex;
        flex-wrap: wrap;

        .header {
            width: 100%;
            border-bottom: 1px solid #eee;
            padding: 0px 0px 12px 0px;

            ::v-deep(.el-statistic) {
                --el-statistic-content-font-size: 28px;
                .statistic-card {
                    height: 100%;
                    border-radius: 4px;
                    background-color: var(--el-bg-color-overlay);
                }
                .el-statistic__head {
                    line-height: 30px;

                    .title {
                        width: 100%;
                        display: flex;
                        justify-content: space-between;
                        align-items: center;
                        color: $--color-less;
                        font-size: 15px;
                    }
                }
            }
            .gressContent {
                width: 100%;
                margin-top: 15px;
            }
            .statistic-footer {
                display: flex;
                justify-content: space-between;
                align-items: center;
                flex-wrap: wrap;
                font-size: 14px;
                color: var(--el-text-color-regular);
                margin-top: 10px;
                .chart {
                    width: 100%;
                }
                .footer-item {
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    span:last-child {
                        display: inline-flex;
                        align-items: center;
                        margin-left: 4px;
                        cursor: pointer;
                    }
                }
            }
        }
        .footer {
            width: 100%;
            p {
                margin: 0px;
                line-height: 40px;
                font-size: 14px;
                height: 30px;
            }

            .statistic-footer {
                display: flex;
                justify-content: space-between;
                align-items: center;
                flex-wrap: wrap;
                font-size: 14px;
                color: var(--el-text-color-regular);
                margin-top: 10px;
                .footer-item {
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    span:last-child {
                        display: inline-flex;
                        align-items: center;
                        margin-left: 4px;
                        cursor: pointer;
                    }
                }
            }
        }

        .green {
            color: var(--el-color-success);
        }
        .red {
            color: var(--el-color-error);
        }
    }

    .tabs {
        width: 100%;
        .paneBox {
            width: 100%;
            display: flex;
            .lfChart {
                width: 78%;
            }
            .rgList {
                flex: 1;
            }
            .lfChart,
            .rgList {
                display: flex;
                flex-wrap: wrap;
                .title {
                    width: 100%;
                    color: $--color-less;
                    text-align: left;
                    font-size: 15px;
                }
                .content {
                    width: 100%;
                    margin-top: 20px;

                    .paneRow {
                        width: 100%;
                        display: flex;
                        height: 30px;
                        margin-bottom: 10px;
                        .avatar {
                            width: 35px;
                            display: flex;
                            align-items: center;
                        }
                        .info {
                            flex: 1;
                            display: flex;
                            flex-wrap: wrap;
                            align-items: center;
                            align-content: baseline;
                            p {
                                font-size: 14px;
                                margin: 0px;
                                line-height: 30px;
                                width: 100%;
                            }
                        }
                        .status {
                            width: 70px;
                            display: flex;
                            font-size: 14px;
                            justify-content: center;
                            align-items: center;
                            color: $--color-less;
                        }
                    }
                }
            }
        }
    }
}
// 兼容手机端
.mobile {
    .app-container {
        .paneBox {
            flex-wrap: wrap;
            .lfChart,
            .rgList {
                width: 100%;
                margin-bottom: 30px;
            }
        }
        .box-card {
            .searchChart {
                display: none;
            }
        }
    }
}
</style>
